package com.unitd.base.frame.util;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * 异常信息处理工具类
 *
 * @author hudan
 * @version 1.0
 * @filename ExceptionUtil.java
 * @copyright www.unitd.com
 * @date 2020-07-08
 */
public class ExceptionUtil {

    /**
     * 根据异常对象,得到异常信息详情
     *
     * @param e 异常对象
     * @return 异常描述信息
     */
    public static String getExceptionMsg(Throwable e) {
        StringWriter sw = new StringWriter();

        try {
            e.printStackTrace(new PrintWriter(sw));
        } finally {
            try {
                sw.close();
            } catch (IOException var8) {
                var8.printStackTrace();
            }

        }

        return sw.getBuffer().toString().replaceAll("\\$", "T");
    }
}